
using UnityEngine;
using UnityEngine.InputSystem;

[CreateAssetMenu(fileName = "PlayerInput_SO", menuName = "Input/PlayerInput")]
public class PlayerInput_SO : ScriptableObject, InputControls.IPlayerInputActions
{

    InputControls inputActions;

    private void OnEnable()
    {
        inputActions = new InputControls();

        inputActions.PlayerInput.SetCallbacks(this);
    }
    public void EnablePlayerInput()
    {
        SwitchActionMap(inputActions.PlayerInput);
    }

    void SwitchActionMap(InputActionMap actionMap)
    {
        inputActions.Disable();
        actionMap.Enable();
    }

    public void DisableAllInputs()
    {
        inputActions.Disable();
    }

    public void OnMove(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            EventHandler.CallMoveEvent(context.ReadValue<Vector2>());
        }
        if (context.canceled)
        {
            EventHandler.CallStopMoveEvent();
        }
    }
}
